﻿using System.Globalization;
using FlickrApi.Configuration;

namespace FlickrApi.Models
{
    public class Photo
    {
        internal IFlickrApiConfiguration Configuration { get; set; }
        public string Id { get; set; }
        public string Secret { get; set; }
        public string Server { get; set; }
        public long Farm { get; set; }
        public string Title { get; set; }
        public bool IsPrimary { get; set; }
        public string Url
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", string.Empty);
            }
        }
        public string SmallSquareUrl75X75
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_s");
            }
        }
        public string LargeSquareUrl150X150
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_q");
            }
        }
        public string ThumbnailUrl100
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_t");
            }
        }
        public string Small240Url
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_m");
            }
        }
        public string Small320Url
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_n");
            }
        }
        public string Medium500Url
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_-");
            }
        }
        public string MediumUrl640X640
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_z");
            }
        }
        public string MediumUrl800X800
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_c");
            }
        }
        public string Large1024Url
        {
            get
            {
                return Configuration.UrlFormatString
                        .Replace("{farm-id}", Farm.ToString(CultureInfo.InvariantCulture))
                        .Replace("{server-id}", Server)
                        .Replace("{id}", Id)
                        .Replace("{secret}", Secret)
                        .Replace("{suffix}", "_b");
            }
        }
        /*
         * According to https://www.flickr.com/services/api/misc.urls.html
         * https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg
	        or
        https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}_[mstzb].jpg
	        or
        https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)
        * Before November 18th, 2011 the API returned image URLs with hostnames like: "farm{farm-id}.static.flickr.com". Those URLs are still supported.

        Size Suffixes

        The letter suffixes are as follows:

        s	small square 75x75
        q	large square 150x150
        t	thumbnail, 100 on longest side
        m	small, 240 on longest side
        n	small, 320 on longest side
        -	medium, 500 on longest side
        z	medium 640, 640 on longest side
        c	medium 800, 800 on longest side†
        b	large, 1024 on longest side*
        o	original image, either a jpg, gif or png, depending on source format
        */


    }
}
